package lowijs.XfireClient;

import java.util.*;

import lowijs.XfireClient.event.*;

public class Conversation {
	private final ArrayList<IM> ims =
		new ArrayList<IM>();
	
	private Friend f;
	private int imindex = 1;
		
	public Conversation(Friend f) {
		this.f = f;
	}
	
	public ArrayList<IM> getMessages() {
		return ims;
	}
	
	public Friend getFriend() {
		return f;
	}
	
	public void receiveIM(IM im) {
		ims.add(im);
		imindex++;
	}
	
	public void sendIM(String message) {
		if (!f.isOnline())
			return;
		IM im = new IM(null, message);
		ims.add(im);
		imindex++;
		SendImEvent sie = new SendImEvent(message, f.getSid(), imindex);
		EventManager.fireEvent(sie);

	}
}
